﻿using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace FAQ_UI
{
	internal class BitmapDrawable : Drawable
	{
		public BitmapImage bitmap { get; private set; }

		public BitmapDrawable(byte[] b) : this(FAQUtil.loadBitmap(b))
		{
		}

		public BitmapDrawable(BitmapImage bitmapImage)
		{
			bitmap = bitmapImage;
		}

		public PixelFormat Format
		{ get { return bitmap.Format; } }
		public int PixelWidth
		{ get { return bitmap.PixelWidth; } }
		public int PixelHeight
		{ get { return bitmap.PixelHeight; } }

		public override void draw(DrawingContext canvas)
		{
			canvas.DrawImage(bitmap, bounds);
		}

		public override double getIntrinsicWidth()
		{
			return bitmap == null ? 0 : bitmap.PixelWidth;
		}

		public override double getIntrinsicHeight()
		{
			return bitmap == null ? 0 : bitmap.PixelHeight;
		}
	}
}